home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / phjcp.bst < prev    next >
Lisp/Scheme  |  1992-07-19  |  61KB  |  1,889 lines

  1. % BibTeX styles for various physics journals (27-Feb-1990).
  2. % This file, physics.btx, is based on the file btxbst.doc.
  3.     % Please notify Charles Karney (Karney@Princeton.EDU)
  4.     % of any bugs, improvements, etc.
  5. % Run this file through cpp to get specific versions.  I have written
  6. % a version of cpp within Emacs.  To access it put
  7. %    (autoload 'cpp "tex$bibtex:cpp"        ; Use cpp for BibTeX styles
  8. %          "C preprocessor"
  9. %          t)
  10. % into your .emacs file.  Read in this file with
  11. %    emacs tex$bibtex:physics.btx
  12. % and run cpp with e.g.,
  13. %    M-x cpp <ret> aip <ret>
  14. % Save the resulting file to tex$latex:aip.bst.
  15. % To accomodate the variations we need (in addition to the definitions below)
  16. %    ATIT_SUPPRESS:    do not include the titles of journal articles
  17. %    NAME_INVERT:    put the initials last
  18. %    NAME_UPPER:    convert names to all caps.
  19. %    MONTH_SUPPRESS:    do not include months in journal articles
  20. %    PAREN_DATE:    dates go in parens in journal articles
  21. %    DATE_FIRST:    dates go before page numbers
  22. %    VOLUME_SPACE:    volume set off with space (not colon)
  23. %    NUM_SUPPRESS:    do not include numbers in journal articles
  24. %    BOLD_VOL:    volume numbers in bold face in journal articles
  25. %    BRACKET_NOTE:    notes in brackets
  26. %    PAGE_START_J:    include only starting page for journal articles
  27. %    PAGE_START_O:    include only starting page for other entries
  28. %    PAGE_ABBREV:    abbreviate page to p. and pages to pp.
  29. %    PHYSICS_JOUR:    include abbreviations for Physics journals
  30. %    COMMA_DELIMIT:    use comma (instead of period) to divide a citation
  31. %    NOTE_SUPPRESS:    suppress the note
  32. %    MAX_NAMES:    max number of authors before using et al (0 = infinity)
  33. %    MIN_NAMES:    number of authors to list with et al.
  34. %    EDIT_VAR:    use "edited by ..." instead of "..., editors"
  35. %    RMP_LABELS:    create RMP-style labels
  36. %    KEY_CITE:    use key as label
  37. %    NAMED_REFS:    use (Smith, 1988) style of citations
  38. %    CSC_NAMES:    names set in caps and small caps
  39. %    JOUR_DEEMPH:    don't emphasize journal name
  40. %    ETAL_EMPH:    emphasize et al.
  41. %    ALT_INCOLL    alternate ordering of fields in incollections
  42. % These are all boolean (0 or 1) except for MAX_NAMES and MIN_NAMES.
  43. % These need to satisfy 0 <= MIN_NAMES <= MAX_NAMES.
  44. % The rule here is that if all these are defined to be zero, we revert to
  45. % the standard styles.  For that reason we initialize them all to 0.
  46. % These are the original macros
  47.     % For Journal of Computational Physics
  48.     % Cris Barnes and Dave Mikkelson, 9/25/89
  49. % This is the start of btxbst.doc
  50. % BibTeX `plain' family
  51.     % version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
  52.     % Copyright (C) 1985, all rights reserved.
  53.     % Copying of this file is authorized only if either
  54.     % (1) you make absolutely no changes to your copy, including name, or
  55.     % (2) if you do make changes, you name it something other than
  56.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  57.     % This restriction helps ensure that all standard styles are identical.
  58.     % The file btxbst.doc has the documentation for this style.
  59. % Please notify Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU) of any bugs in
  60. % these standard styles or in this documentation file.
  61. %
  62. % This is file btxbxt.doc; it helps document bibliography styles,
  63. % and is also a template file that you can use to make
  64. % several different style files, if you have access to a C preprocessor.
  65. % For example, the standard styles were made by doing something like
  66. %    cpp -P -DPLAIN btxbst.doc plain.txt
  67. %    cpp -P -DUNSRT btxbst.doc unsrt.txt
  68. %    cpp -P -DALPHA btxbst.doc alpha.txt
  69. %    cpp -P -DABBRV btxbst.doc abbrv.txt
  70. % and then renaming after removing unwanted comments and blank lines.
  71. % If you don't have access,
  72. % you can edit this file by hand to imitate the preprocessor,
  73. % with the following explanation of the C preprocessor constructs used here.
  74. %
  75. % The output of the preprocessor is the same as the input, except that certain
  76. % lines will be excluded (and some blank lines will be added).  The sequence
  77. %    #if VAR
  78. %        lines to be included when VAR is not zero
  79. %    #else
  80. %        lines to be included when VAR is zero
  81. %    #endif
  82. % (with the #-signs appearing in column 1) means that one set or the other of
  83. % the lines are to be included depending on the value of VAR.
  84. % The #else part is optional.  Comments can be added after #else and #endif.
  85. % Variables can be set by
  86. %    #define VAR value
  87. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  88. % to see if it has none.
  89. % Another #if form used in this file is #if !VAR, which includes the lines
  90. % after the #if only if VAR is zero.
  91. %
  92. % Convention: Use all uppercase identifiers for these preprocessor variables
  93. % so you can spot them easily
  94. %
  95. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  96. % or ABBRV (though PLAIN will be used by default if none is given),
  97. % and the following lines will set various boolean variables to control the
  98. % various lines that are chosen from the rest of the file.
  99. % Each boolean variable should be set true (1) or false (0) in each style.
  100. % Here are the current variables, and their meanings:
  101. %    0:    an alphabetic label is used (if false then a numeric
  102. %                label is used)
  103. %    0:        the entries should be sorted by label (if nonnumeric)
  104. %                and other info, like authors (if false, then
  105. %                entries remain in order of occurrence)
  106. %    0:    the authors, editors, etc., get the full names as
  107. %                given in the bibliography file (if false, the first
  108. %                names become initials)
  109. %    0:    titles of non-"books" (e.g., articles) should be
  110. %                converted to lower-case, except the first letter or
  111. %                first letter after a colon
  112. %                (if false then they appear as in the database)
  113. %    0:    months are spelled out in full (if false, then
  114. %                they're abbreviated)
  115. %    0:    macro journal names are spelled out in full
  116. %                (if false then they are abbreviated, currently
  117. %                as they appear in ACM publications)
  118. %#        define PLAIN 1
  119. %
  120. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  121. %    in "A Handbook for Scholars".  Book-like titles are italicized
  122. %    (emphasized) and non-book titles are converted to sentence
  123. %    capitilization (and not enclosed in quotes).
  124. %    This file outputs a \newblock between major blocks of an entry
  125. %    (the name \newblock is analogous to the names \newline and \newpage)
  126. %    so that the user can obtain an "open" format, which has a line break
  127. %    before each block and lines after the first are indented within blocks,
  128. %    by giving the optional \documentstyle argument `openbib';
  129. %    The default is the "closed" format---blocks runs together.
  130. %
  131. %   Citation alphabetic label format:
  132. %        [Knu73] for single author (or editor or key)
  133. %        [AHU83] (first letters of last names) for multiple authors
  134. %
  135. %   Citation label numberic format:
  136. %        [number]
  137. %
  138. %   Reference list ordering for sorted, alphabetic lables:
  139. %        alphabetical by citation label, then by author(s) or whatever
  140. %        passes for author in the absence of one, then by year,
  141. %        then title
  142. %
  143. %   Reference list ordering for sorted, numeric lables:
  144. %        alphabetical by author(s) or whatever passes
  145. %        for author in the absence of one, then by year, then title
  146. %
  147. %   Reference list ordering for unsorted:
  148. %        by the order cited in the text
  149. %
  150. %   History
  151. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  152. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  153. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik.
  154. %    2/17/85    (HWT)    Template file and other standard styles made.
  155. %    3/28/85    (OP)    First release, version 0.98b for BibTeX 0.98f.
  156. %    5/ 9/85    (OP)    Version 0.98c for BibTeX 0.98i:
  157. %            fixed Theoretical Computer Science macro name;
  158. %            fixed the format.vol.num.pages function.
  159. %    1/24/88    (OP)    Version 0.99a for BibTeX 0.99a, main changes:
  160. %            assignment operator (:=) arguments reversed;
  161. %            the preamble$ function outputs the database PREAMBLE;
  162. %            entry.max$ and global.max$ (built-in) variables replace
  163. %            entry.string.max and global.string.max functions;
  164. %            alphabetizing by year then title, not just title;
  165. %            many unnecessary ties removed; \it ==> \em;
  166. %            the `alpha' style uses a superscripted `+' instead of a
  167. %            `*' for unnamed names in constructing the label;
  168. %            the `abbrv' style now uses "Mar." and "Sept.";
  169. %            the functions calc.label and presort now look at just
  170. %            the fields they're supposed to;
  171. %            BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
  172. %            INBOOK and INCOLLECTION take an optional type (e.g.
  173. %            type = "Section"), overriding the default "chapter";
  174. %            BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
  175. %            either volume or number, not just volume;
  176. %            INCOLLECTION now allows an edition and series field;
  177. %            PROCEEDINGS and INPROCEEDINGS now use the address field
  178. %            to tell where a conference was held;
  179. %            INPROCEEDINGS and PROCEEDINGS now allow either volume
  180. %            or number, and also a series field;
  181. %            MASTERSTHESIS and PHDTHESIS accept types other than
  182. %            "Master's thesis" and "PhD thesis";
  183. %            UNPUBLISHED now outputs, in one block, note then date;
  184. %            MANUAL now prints out the organization in
  185. %            the first block if the author field is empty;
  186. %            MISC can't be empty---it requires some optional field.
  187. %    3/23/88    (OP)    Version 0.99b for BibTeX 0.99c---changed the three
  188. %            erroneous occurrences of `cite ' to `cite$ '; this
  189. %            change didn't affect the four standard styles, so the
  190. %            0.99a versions of those styles are still current.
  191. %
  192. % The ENTRY declaration
  193. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  194. %   but no fullauthor or editors fields because BibTeX does name handling.
  195. %   The annote field is commented out here because this family doesn't
  196. %   include an annotated bibliography style.  And in addition to the fields
  197. %   listed here, BibTeX has a built-in crossref field, explained later.
  198. ENTRY
  199. % Fields:
  200.   { address
  201. %        Usually the address of a publisher or other type of organization.
  202. %        Put information in this field only if it helps the reader find the
  203. %        thing---for example you should omit the address of a major
  204. %        publisher entirely.  For a PROCEEDINGS or an INPROCEEDINGS,
  205. %        however, it's the address of the conference; for those two entry
  206. %        types, include the publisher's or organization's address, if
  207. %        necessary, in the publisher or organization field.
  208. %    annote
  209. %        Long annotation---for annotated bibliographies (begins sentence).
  210.     author
  211. %        Name(s) of author(s), in BibTeX name format.
  212.     booktitle
  213. %        Book title when the thing being referenced isn't the whole book.
  214. %        For book entries, the title field should be used instead.
  215.     chapter
  216. %        Chapter (or section or whatever) number.
  217.     edition
  218. %        Edition of a book---should be an ordinal (e.g., "Second").
  219.     editor
  220. %        Name(s) of editor(s), in BibTeX name format.
  221. %        If there is also an author field, then the editor field should be
  222. %        for the book or collection that the work appears in.
  223.     howpublished
  224. %         How something strange has been published (begins sentence).
  225.     institution
  226. %        Sponsoring institution of a technical report.
  227.     journal
  228. %        Journal name (macros are provided for many).
  229.     key
  230. %        Alphabetizing, labeling, and cross-referencing key
  231. %        (needed when an entry has no author or editor).
  232.     month
  233. %        Month (macros are provided).
  234.     note
  235. %        To help the reader find a reference (begins sentence).
  236.     number
  237. %        Number of a journal or technical report, or of a work in a series.
  238.     organization
  239. %        Organization sponsoring a conference (or publishing a manual); if
  240. %        the editor (or author) is empty, and if the organization produces
  241. %        an awkward label or cross reference, you should put appropriately
  242. %        condensed organization information in the key field as well.
  243.     pages
  244. %        Page number or numbers (use `--' to separate a range, use `+'
  245. %        to indicate pages following that don't form a simple range).
  246.     publisher
  247. %        Publisher name.
  248.     school
  249. %        School name (for theses).
  250.     series
  251. %        The name of a series or set of books.
  252. %        An individual book will will also have it's own title.
  253.     title
  254. %        The title of the thing you're referred to.
  255.     type
  256. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  257. %        the default "Technical Report"; or, similarly, the type of a
  258. %        thesis; or of a part of a book.
  259.     volume
  260. %        The volume number of a journal or multivolume work.
  261.     year
  262. %        The year should contain only numerals (technically, it should end
  263. %        with four numerals, after purification; doesn't a begin sentence).
  264.   }
  265. % There are no integer entry variables
  266.   {}
  267. % These string entry variables are used to form the citation label.
  268. % In a storage pinch, sort.label can be easily computed on the fly.
  269.   { label }
  270. % Each entry function starts by calling output.bibitem, to write the
  271. % \bibitem and its arguments to the .BBL file.  Then the various fields
  272. % are formatted and printed by output or output.check.  Those functions
  273. % handle the writing of separators (commas, periods, \newblock's),
  274. % taking care not to do so when they are passed a null string.
  275. % Finally, fin.entry is called to add the final period and finish the
  276. % entry.
  277. %
  278. % A bibliographic reference is formatted into a number of `blocks':
  279. % in the open format, a block begins on a new line and subsequent
  280. % lines of the block are indented.  A block may contain more than
  281. % one sentence (well, not a grammatical sentence, but something to
  282. % be ended with a sentence ending period).  The entry functions should
  283. % call new.block whenever a block other than the first is about to be
  284. % started.  They should call new.sentence whenever a new sentence is
  285. % to be started.  The output functions will ensure that if two
  286. % new.sentence's occur without any non-null string being output between
  287. % them then there won't be two periods output.  Similarly for two
  288. % successive new.block's.
  289. %
  290. % The output routines don't write their argument immediately.
  291. % Instead, by convention, that argument is saved on the stack to be
  292. % output next time (when we'll know what separator needs to come
  293. % after it).  Meanwhile, the output routine has to pop the pending
  294. % output off the stack, append any needed separator, and write it.
  295. %
  296. % To tell which separator is needed, we maintain an output.state.
  297. % It will be one of these values:
  298. %    before.all        just after the \bibitem
  299. %    mid.sentence        in the middle of a sentence: comma needed
  300. %                    if more sentence is output
  301. %    after.sentence        just after a sentence: period needed
  302. %    after.block        just after a block (and sentence):
  303. %                    period and \newblock needed.
  304. % Note: These styles don't use after.sentence
  305. %
  306. % VAR: output.state : INTEGER        -- state variable for output
  307. %
  308. % The output.nonnull function saves its argument (assumed to be nonnull)
  309. % on the stack, and writes the old saved value followed by any needed
  310. % separator.  The ordering of the tests is decreasing frequency of
  311. % occurrence.
  312. %
  313. % output.nonnull(s) ==
  314. %  BEGIN
  315. %    s := argument on stack
  316. %    if output.state = mid.sentence then
  317. %        write$(pop() * ", ")
  318. %          -- "pop" isn't a function: just use stack top
  319. %    else
  320. %        if output.state = after.block then
  321. %        write$(add.period$(pop()))
  322. %        newline$
  323. %        write$("\newblock ")
  324. %        else
  325. %        if output.state = before.all then
  326. %            write$(pop())
  327. %        else        -- output.state should be after.sentence
  328. %            write$(add.period$(pop()) * " ")
  329. %        fi
  330. %        fi
  331. %        output.state := mid.sentence
  332. %    fi
  333. %    push s on stack
  334. %  END
  335. %
  336. % The output function calls output.nonnull if its argument is non-empty;
  337. % its argument may be a missing field (thus, not necessarily a string)
  338. %
  339. % output(s) ==
  340. %  BEGIN
  341. %    if not empty$(s) then output.nonnull(s)
  342. %    fi
  343. %  END
  344. %
  345. % The output.check function is the same as the output function except that, if
  346. % necessary, output.check warns the user that the t field shouldn't be empty
  347. % (this is because it probably won't be a good reference without the field;
  348. % the entry functions try to make the formatting look reasonable even when
  349. % such fields are empty).
  350. %
  351. % output.check(s,t) ==
  352. %  BEGIN
  353. %    if empty$(s) then
  354. %        warning$("empty " * t * " in " * cite$)
  355. %    else output.nonnull(s)
  356. %    fi
  357. %  END
  358. %
  359. % The output.bibitem function writes the \bibitem for the current entry
  360. % (the label should already have been set up), and sets up the separator
  361. % state for the output functions.  And, it leaves a string on the stack
  362. % as per the output convention.
  363. %
  364. % output.bibitem ==
  365. %  BEGIN
  366. %    newline$
  367. %    write$("\bibitem[")    % for alphabetic labels,
  368. %    write$(label)        % these three lines
  369. %    write$("]{")        % are used
  370. %    write$("\bibitem{")        % this line for numeric labels
  371. %    write$(cite$)
  372. %    write$("}")
  373. %    push "" on stack
  374. %    output.state := before.all
  375. %  END
  376. %
  377. % The fin.entry function finishes off an entry by adding a period to the
  378. % string remaining on the stack.  If the state is still before.all
  379. % then nothing was produced for this entry, so the result will look bad,
  380. % but the user deserves it. (We don't omit the whole entry because the
  381. % entry was cited, and a bibitem is needed to define the citation label.)
  382. %
  383. % fin.entry ==
  384. %  BEGIN
  385. %    write$(add.period$(pop()))
  386. %    newline$
  387. %  END
  388. %
  389. % The new.block function prepares for a new block to be output, and
  390. % new.sentence prepares for a new sentence.
  391. %
  392. % new.block ==
  393. %  BEGIN
  394. %    if output.state <> before.all then
  395. %        output.state := after.block
  396. %    fi
  397. %  END
  398. %
  399. % new.sentence ==
  400. %  BEGIN
  401. %    if output.state <> after.block then
  402. %        if output.state <> before.all then
  403. %        output.state :=  after.sentence
  404. %        fi
  405. %    fi
  406. %  END
  407. %
  408. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  409. FUNCTION {init.state.consts}
  410. { #0 'before.all :=
  411.   #1 'mid.sentence :=
  412.   #2 'after.sentence :=
  413.   #3 'after.block :=
  414. }
  415. % the variables s and t are temporary string holders
  416. STRINGS { s t }
  417. FUNCTION {output.nonnull}
  418. { 's :=
  419.   output.state mid.sentence =
  420.     { ", " * write$ }
  421.     { output.state after.block =
  422.     { "," * write$
  423.       newline$
  424.       "\newblock " write$
  425.     }
  426.     { output.state before.all =
  427.         'write$
  428.         { add.period$ " " * write$ }
  429.       if$
  430.     }
  431.       if$
  432.       mid.sentence 'output.state :=
  433.     }
  434.   if$
  435.   s
  436. }
  437. FUNCTION {output}
  438. { duplicate$ empty$
  439.     'pop$
  440.     'output.nonnull
  441.   if$
  442. }
  443. FUNCTION {output.check}
  444. { 't :=
  445.   duplicate$ empty$
  446.     { pop$ "empty " t * " in " * cite$ * warning$ }
  447.     'output.nonnull
  448.   if$
  449. }
  450. FUNCTION {output.bibitem}
  451. { newline$
  452.   "\bibitem{" write$
  453.   cite$ write$
  454.   "}" write$
  455.   newline$
  456.   ""
  457.   before.all 'output.state :=
  458. }
  459. % This function finishes all entries.
  460. FUNCTION {fin.entry}
  461. { add.period$
  462.   write$
  463.   newline$
  464. }
  465. FUNCTION {new.block}
  466. { output.state before.all =
  467.     'skip$
  468.     { after.block 'output.state := }
  469.   if$
  470. }
  471. FUNCTION {new.sentence}
  472. { skip$
  473. }
  474. % These three functions pop one or two (integer) arguments from the stack
  475. % and push a single one, either 0 or 1.
  476. % The 'skip$ in the `and' and `or' functions are used because
  477. % the corresponding if$ would be idempotent
  478. FUNCTION {not}
  479. {   { #0 }
  480.     { #1 }
  481.   if$
  482. }
  483. FUNCTION {and}
  484. {   'skip$
  485.     { pop$ #0 }
  486.   if$
  487. }
  488. FUNCTION {or}
  489. {   { pop$ #1 }
  490.     'skip$
  491.   if$
  492. }
  493. % Sometimes we begin a new block only if the block will be big enough.  The
  494. % new.block.checka function issues a new.block if its argument is nonempty;
  495. % new.block.checkb does the same if either of its TWO arguments is nonempty.
  496. FUNCTION {new.block.checka}
  497. { empty$
  498.     'skip$
  499.     'new.block
  500.   if$
  501. }
  502. FUNCTION {new.block.checkb}
  503. { empty$
  504.   swap$ empty$
  505.   and
  506.     'skip$
  507.     'new.block
  508.   if$
  509. }
  510. % The new.sentence.check functions are analogous.
  511. FUNCTION {new.sentence.checka}
  512. { empty$
  513.     'skip$
  514.     'new.sentence
  515.   if$
  516. }
  517. FUNCTION {new.sentence.checkb}
  518. { empty$
  519.   swap$ empty$
  520.   and
  521.     'skip$
  522.     'new.sentence
  523.   if$
  524. }
  525. % Here are some functions for formatting chunks of an entry.
  526. % By convention they either produce a string that can be followed by
  527. % a comma or period (using add.period$, so it is OK to end in a period),
  528. % or they produce the null string.
  529. %
  530. % A useful utility is the field.or.null function, which checks if the
  531. % argument is the result of pushing a `missing' field (one for which no
  532. % assignment was made when the current entry was read in from the database)
  533. % or the result of pushing a string having no non-white-space characters.
  534. % It returns the null string if so, otherwise it returns the field string.
  535. % Its main (but not only) purpose is to guarantee that what's left on the
  536. % stack is a string rather than a missing field.
  537. %
  538. % field.or.null(s) ==
  539. %  BEGIN
  540. %    if empty$(s) then return ""
  541. %    else return s
  542. %  END
  543. %
  544. % Another helper function is emphasize, which returns the argument emphazised,
  545. % if that is non-empty, otherwise it returns the null string.  Italic
  546. % corrections aren't used, so this function should be used when punctation
  547. % will follow the result.
  548. %
  549. % emphasize(s) ==
  550. %  BEGIN
  551. %    if empty$(s) then return ""
  552. %    else return "{\em " * s * "}"
  553. %
  554. % The format.names function formats the argument (which should be in
  555. % BibTeX name format) into "First Von Last, Junior", separated by commas
  556. % and with an "and" before the last (but ending with "et~al." if the last
  557. % of multiple authors is "others").  This function's argument should always
  558. % contain at least one name.
  559. %
  560. % VAR: nameptr, namesleft, numnames: INTEGER
  561. % pseudoVAR: nameresult: STRING        (it's what's accumulated on the stack)
  562. %
  563. % format.names(s) ==
  564. %  BEGIN
  565. %    nameptr := 1
  566. %    numnames := num.names$(s)
  567. %    namesleft := numnames
  568. %    while namesleft > 0
  569. %      do
  570. %                % for full names:
  571. %        t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
  572. %                % for abbreviated first names:
  573. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  574. %        if nameptr > 1 then
  575. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  576. %        else if numnames > 2
  577. %               then nameresult := nameresult * ","
  578. %             fi
  579. %             if t = "others"
  580. %               then nameresult := nameresult * " et~al."
  581. %               else nameresult := nameresult * " and " * t
  582. %             fi
  583. %        fi
  584. %        else nameresult := t
  585. %        fi
  586. %        nameptr := nameptr + 1
  587. %        namesleft := namesleft - 1
  588. %      od
  589. %    return nameresult
  590. %  END
  591. %
  592. % The format.authors function returns the result of format.names(author)
  593. % if the author is present, or else it returns the null string
  594. %
  595. % format.authors ==
  596. %  BEGIN
  597. %    if empty$(author) then return ""
  598. %    else return format.names(author)
  599. %    fi
  600. %  END
  601. %
  602. % Format.editors is like format.authors, but it uses the editor field,
  603. % and appends ", editor" or ", editors"
  604. %
  605. % format.editors ==
  606. %  BEGIN
  607. %    if empty$(editor) then return ""
  608. %    else
  609. %        if num.names$(editor) > 1 then
  610. %        return format.names(editor) * ", editors"
  611. %        else
  612. %        return format.names(editor) * ", editor"
  613. %        fi
  614. %    fi
  615. %  END
  616. %
  617. % Other formatting functions are similar, so no "comment version" will be
  618. % given for them.
  619. %
  620. % The `pop$' in this function gets rid of the duplicate `empty' value and
  621. % the `skip$' returns the duplicate field value
  622. FUNCTION {field.or.null}
  623. { duplicate$ empty$
  624.     { pop$ "" }
  625.     'skip$
  626.   if$
  627. }
  628. FUNCTION {emphasize}
  629. { duplicate$ empty$
  630.     { pop$ "" }
  631.     { "{\em " swap$ * "}" * }
  632.   if$
  633. }
  634. FUNCTION {caps}
  635. { duplicate$ empty$
  636.     { pop$ "" }
  637.     { "{\sc " swap$ * "}" * }
  638.   if$
  639. }
  640. FUNCTION {embolden}
  641. { duplicate$ empty$
  642.     { pop$ "" }
  643.     { "{\bf " swap$ * "}" * }
  644.   if$
  645. }
  646. FUNCTION {paren}
  647. { duplicate$ empty$
  648.     { pop$ "" }
  649.     { "(" swap$ * ")" * }
  650.   if$
  651. }
  652. INTEGERS { nameptr namesleft numnames }
  653. FUNCTION {format.names}
  654. { 's :=
  655.   #1 'nameptr :=
  656.   s num.names$ 'numnames :=
  657.   numnames 'namesleft :=
  658.     { namesleft #0 > }
  659.     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
  660.       t "others" =
  661.     'skip$
  662.     { t caps 't := }
  663.       if$
  664.       nameptr #1 >
  665.     { namesleft #1 >
  666.         { ", " * t * }
  667.         { numnames #2 >
  668.         { "," * }
  669.         'skip$
  670.           if$
  671.           t "others" =
  672.         { " et~al." * }
  673.         { " and " * t * }
  674.           if$
  675.         }
  676.       if$
  677.     }
  678.     't
  679.       if$
  680.       nameptr #1 + 'nameptr :=
  681.       namesleft #1 - 'namesleft :=
  682.     }
  683.   while$
  684. }
  685. FUNCTION {format.authors}
  686. { author empty$
  687.     { "" }
  688.     { author format.names }
  689.   if$
  690. }
  691. FUNCTION {format.editors}
  692. { editor empty$
  693.     { "" }
  694.     { editor format.names
  695.       editor num.names$ #1 >
  696.     { ", editors" * }
  697.     { ", editor" * }
  698.       if$
  699.     }
  700.   if$
  701. }
  702. FUNCTION {format.edited}
  703. { editor empty$
  704.     { "" }
  705.     { "edited by " editor format.names * }
  706.   if$
  707. }
  708. % The format.title function is used for non-book-like titles.
  709. % For most styles we convert to lowercase (except for the very first letter,
  710. % and except for the first one after a colon (followed by whitespace)),
  711. % and hope the user has brace-surrounded words that need to stay capitilized;
  712. % for some styles, however, we leave it as it is in the database.
  713. FUNCTION {format.title}
  714. { title empty$
  715.     { "" }
  716.     'title
  717.   if$
  718. }
  719. % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
  720. % constant glob_str_size, the maximum length of a global string variable.
  721. % Analogously, BibTeX sets the global integer variable entry.max$ to
  722. % ent_str_size, the maximum length of an entry string variable.
  723. % The style designer may change these if necessary (but this is unlikely)
  724. % The n.dashify function makes each single `-' in a string a double `--'
  725. % if it's not already
  726. %
  727. % pseudoVAR: pageresult: STRING        (it's what's accumulated on the stack)
  728. %
  729. % n.dashify(s) ==
  730. %  BEGIN
  731. %    t := s
  732. %    pageresult := ""
  733. %    while (not empty$(t))
  734. %      do
  735. %        if (first character of t = "-")
  736. %          then
  737. %        if (next character isn't)
  738. %          then
  739. %            pageresult := pageresult * "--"
  740. %            t := t with the "-" removed
  741. %          else
  742. %            while (first character of t = "-")
  743. %              do
  744. %            pageresult := pageresult * "-"
  745. %            t := t with the "-" removed
  746. %              od
  747. %        fi
  748. %          else
  749. %        pageresult := pageresult * the first character
  750. %        t := t with the first character removed
  751. %        fi
  752. %      od
  753. %    return pageresult
  754. %  END
  755. FUNCTION {n.dashify}
  756. { 't :=
  757.   ""
  758.     { t empty$ not }
  759.     { t #1 #1 substring$ "-" =
  760.     { t #1 #2 substring$ "--" = not
  761.         { "--" *
  762.           t #2 global.max$ substring$ 't :=
  763.         }
  764.         {   { t #1 #1 substring$ "-" = }
  765.         { "-" *
  766.           t #2 global.max$ substring$ 't :=
  767.         }
  768.           while$
  769.         }
  770.       if$
  771.     }
  772.     { t #1 #1 substring$ *
  773.       t #2 global.max$ substring$ 't :=
  774.     }
  775.       if$
  776.     }
  777.   while$
  778. }
  779. FUNCTION {first.page}
  780. { 't :=
  781.   ""
  782.     {  t empty$ not t #1 #1 substring$ "-" = not and }
  783.     { t #1 #1 substring$ *
  784.       t #2 global.max$ substring$ 't :=
  785.     }
  786.   while$
  787. }
  788. % The format.date function is for the month and year, but we give a warning if
  789. % there's an empty year but the month is there, and we return the empty string
  790. % if they're both empty.
  791. FUNCTION {format.date}
  792. { year empty$
  793.     { "" }
  794.     'year
  795.   if$
  796. }
  797. % The format.btitle is for formatting the title field when it is a book-like
  798. % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
  799. FUNCTION {format.btitle}
  800. { title emphasize
  801. }
  802. % For several functions we'll need to connect two strings with a
  803. % tie (~) if the second one isn't very long (fewer than 3 characters).
  804. % The tie.or.space.connect function does that.  It concatenates the two
  805. % strings on top of the stack, along with either a tie or space between
  806. % them, and puts this concatenation back onto the stack:
  807. %
  808. % tie.or.space.connect(str1,str2) ==
  809. %    BEGIN
  810. %    if text.length$(str2) < 3
  811. %      then return the concatenation of str1, "~", and str2
  812. %      else return the concatenation of str1, " ", and str2
  813. %    END
  814. FUNCTION {tie.or.space.connect}
  815. { duplicate$ text.length$ #3 <
  816.     { "~" }
  817.     { " " }
  818.   if$
  819.   swap$ * *
  820. }
  821. % The either.or.check function complains if both fields or an either-or pair
  822. % are nonempty.
  823. %
  824. % either.or.check(t,s) ==
  825. %  BEGIN
  826. %    if empty$(s) then
  827. %        warning$(can't use both " * t * " fields in " * cite$)
  828. %    fi
  829. %  END
  830. FUNCTION {either.or.check}
  831. { empty$
  832.     'pop$
  833.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  834.   if$
  835. }
  836. % The format.bvolume function is for formatting the volume and perhaps
  837. % series name of a multivolume work.  If both a volume and a series field
  838. % are there, we assume the series field is the title of the whole multivolume
  839. % work (the title field should be the title of the thing being referred to),
  840. % and we add an "of <series>".  This function is called in mid-sentence.
  841. FUNCTION {format.bvolume}
  842. { volume empty$
  843.     { "" }
  844.     { "volume" volume tie.or.space.connect
  845.       series empty$
  846.     'skip$
  847.     { " of " * series emphasize * }
  848.       if$
  849.       "volume and number" number either.or.check
  850.     }
  851.   if$
  852. }
  853. % The format.number.series function is for formatting the series name
  854. % and perhaps number of a work in a series.  This function is similar to
  855. % format.bvolume, although for this one the series must exist (and the
  856. % volume must not exist).  If the number field is empty we output either
  857. % the series field unchanged if it exists or else the null string.
  858. % If both the number and series fields are there we assume the series field
  859. % gives the name of the whole series (the title field should be the title
  860. % of the work being one referred to), and we add an "in <series>".
  861. % We capitilize Number when this function is used at the beginning of a block.
  862. FUNCTION {format.number.series}
  863. { volume empty$
  864.     { number empty$
  865.     { series field.or.null }
  866.     { output.state mid.sentence =
  867.         { "number" }
  868.         { "Number" }
  869.       if$
  870.       number tie.or.space.connect
  871.       series empty$
  872.         { "there's a number but no series in " cite$ * warning$ }
  873.         { " in " * series * }
  874.       if$
  875.     }
  876.       if$
  877.     }
  878.     { "" }
  879.   if$
  880. }
  881. % The format.edition function appends " edition" to the edition, if present.
  882. % We lowercase the edition (it should be something like "Third"), because
  883. % this doesn't start a sentence.
  884. FUNCTION {format.edition}
  885. { edition empty$
  886.     { "" }
  887.     { output.state mid.sentence =
  888.     { edition "l" change.case$ " edition" * }
  889.     { edition "t" change.case$ " edition" * }
  890.       if$
  891.     }
  892.   if$
  893. }
  894. % The format.pages function is used for formatting a page range in a book
  895. % (and in rare circumstances, an article).
  896. %
  897. % The multi.page.check function examines the page field for a "-" or "," or "+"
  898. % so that format.pages can use "page" instead of "pages" if none exists.
  899. % Note: global.max$ here means "take the rest of the string"
  900. %
  901. % VAR: multiresult: INTEGER    (actually, a boolean)
  902. %
  903. % multi.page.check(s) ==
  904. %  BEGIN
  905. %    t := s
  906. %    multiresult := false
  907. %    while ((not multiresult) and (not empty$(t)))
  908. %      do
  909. %        if (first character of t = "-" or "," or "+")
  910. %          then multiresult := true
  911. %          else t := t with the first character removed
  912. %        fi
  913. %      od
  914. %    return multiresult
  915. %  END
  916. INTEGERS { multiresult }
  917. FUNCTION {multi.page.check}
  918. { 't :=
  919.   #0 'multiresult :=
  920.     { multiresult not
  921.       t empty$ not
  922.       and
  923.     }
  924.     { t #1 #1 substring$
  925.       duplicate$ "-" =
  926.       swap$ duplicate$ "," =
  927.       swap$ "+" =
  928.       or or
  929.     { #1 'multiresult := }
  930.     { t #2 global.max$ substring$ 't := }
  931.       if$
  932.     }
  933.   while$
  934.   multiresult
  935. }
  936. % This function doesn't begin a sentence so "pages" isn't capitalized.
  937. % Other functions that use this should keep that in mind.
  938. FUNCTION {format.pages}
  939. { pages empty$
  940.     { "" }
  941.     { pages multi.page.check
  942.     { "pp." pages n.dashify tie.or.space.connect }
  943.     { "p." pages tie.or.space.connect }
  944.       if$
  945.     }
  946.   if$
  947. }
  948. FUNCTION {format.pages.a}
  949. { pages empty$
  950.     { "" }
  951.     { "p." pages first.page tie.or.space.connect }
  952.   if$
  953. }
  954. % The format.vol.num.pages function is for the volume, number, and page range
  955. % of a journal article.  We use the format:  vol(number):pages, with some
  956. % variations for empty fields.  This doesn't begin a sentence.
  957. FUNCTION {format.vol.num.pages}
  958. { volume field.or.null embolden
  959.   " " swap$ * *
  960.   pages empty$
  961.     'skip$
  962.     { duplicate$ empty$
  963.     { pop$ format.pages.a }
  964.     { ", " * pages first.page * }
  965.       if$
  966.     }
  967.   if$
  968. }
  969. % The format.chapter.pages, if the chapter is present, puts whatever is in the
  970. % type field (or else "chapter" if type is empty) in front of a chapter number.
  971. % It then appends the pages, if present.  This doesn't begin a sentence.
  972. FUNCTION {format.chapter.pages}
  973. { chapter empty$
  974.     'format.pages
  975.     { type empty$
  976.     { "chapter" }
  977.     { type "l" change.case$ }
  978.       if$
  979.       chapter tie.or.space.connect
  980.       pages empty$
  981.     'skip$
  982.     { ", " * format.pages * }
  983.       if$
  984.     }
  985.   if$
  986. }
  987. % The format.in.ed.booktitle function is used for starting out a sentence
  988. % that begins "In <booktitle>", putting an editor before the title if one
  989. % exists.
  990. FUNCTION {format.in.ed.booktitle}
  991. { booktitle empty$
  992.     { "" }
  993.     { editor empty$
  994.     { "in " booktitle emphasize * }
  995.     { "in " booktitle emphasize * ", " * format.edited * }
  996.       if$
  997.     }
  998.   if$
  999. }
  1000. % The function empty.misc.check complains if all six fields are empty, and
  1001. % if there's been no sorting or alphabetic-label complaint.
  1002. FUNCTION {empty.misc.check}
  1003. { author empty$ title empty$ howpublished empty$
  1004.   month empty$ year empty$ note empty$
  1005.   and and and and and
  1006.     { "all relevant fields are empty in " cite$ * warning$ }
  1007.     'skip$
  1008.   if$
  1009. }
  1010. % The function format.thesis.type returns either the (case-changed) type field,
  1011. % if it is defined, or else the default string already on the stack
  1012. % (like "Master's thesis" or "PhD thesis").
  1013. FUNCTION {format.thesis.type}
  1014. { type empty$
  1015.     'skip$
  1016.     { pop$
  1017.       type "t" change.case$
  1018.     }
  1019.   if$
  1020. }
  1021. % The function format.tr.number makes a string starting with "Technical Report"
  1022. % (or type, if that field is defined), followed by the number if there is one;
  1023. % it returns the starting part (with a case change) even if there is no number.
  1024. % This is used at the beginning of a sentence.
  1025. FUNCTION {format.tr.number}
  1026. { type empty$
  1027.     { "Technical Report" }
  1028.     'type
  1029.   if$
  1030.   number empty$
  1031.     { "t" change.case$ }
  1032.     { number tie.or.space.connect }
  1033.   if$
  1034. }
  1035. % Now come the cross-referencing functions (these are invoked because
  1036. % one entry in the database file(s) cross-references another, by giving
  1037. % the other entry's database key in a `crossref' field).  This feature
  1038. % allows one or more titled things that are part of a larger titled
  1039. % thing to cross-reference the larger thing.  These styles allow for
  1040. % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
  1041. % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
  1042. % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
  1043. % Each of these is explained in more detail later.
  1044. %
  1045. % An ARTICLE entry type may cross reference another ARTICLE (this is
  1046. % intended for when an entire journal is devoted to a single topic---
  1047. % but since there is no JOURNAL entry type, the journal, too, should be
  1048. % classified as an ARTICLE but without the author and title fields).
  1049. % This will result in two warning messages for the journal's entry
  1050. % if it's included in the reference list, but such is life.
  1051. %
  1052. % format.article.crossref ==
  1053. %  BEGIN
  1054. %    if empty$(key) then
  1055. %        if empty$(journal) then
  1056. %        warning$("need key or journal for " * cite$ *
  1057. %                        " to crossref " * crossref)
  1058. %        return(" \cite{" * crossref * "}")
  1059. %        else
  1060. %        return("In " * emphazise.correct (journal) *
  1061. %                        " \cite{" * crossref * "}")
  1062. %        fi
  1063. %    else
  1064. %        return("In " * key * " \cite{" * crossref * "}")
  1065. %    fi
  1066. %  END
  1067. %
  1068. % The other cross-referencing functions are similar, so no "comment version"
  1069. % will be given for them.
  1070. FUNCTION {format.article.crossref}
  1071. { key empty$
  1072.     { journal empty$
  1073.     { "need key or journal for " cite$ * " to crossref " * crossref *
  1074.       warning$
  1075.       ""
  1076.     }
  1077.     { "In {\em " journal * "\/}" * }
  1078.       if$
  1079.     }
  1080.     { "In " key * }
  1081.   if$
  1082.   " \cite{" * crossref * "}" *
  1083. }
  1084. % We use just the last names of editors for a cross reference: either
  1085. % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
  1086. % whether there are one, or two, or more than two editors.
  1087. FUNCTION {format.crossref.editor}
  1088. { editor #1 "{vv~}{ll}" format.name$ caps
  1089.   editor num.names$ duplicate$
  1090.   #2 >
  1091.     { pop$ " et~al." * }
  1092.     { #2 <
  1093.     'skip$
  1094.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1095.         { " et~al." * }
  1096.         { " and " * editor #2 "{vv~}{ll}" format.name$ caps * }
  1097.       if$
  1098.     }
  1099.       if$
  1100.     }
  1101.   if$
  1102. }
  1103. % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
  1104. % multivolume work) may cross reference another BOOK (the entire multivolume).
  1105. % Usually there will be an editor, in which case we use that to construct the
  1106. % cross reference; otherwise we use a nonempty key field or else the series
  1107. % field (since the series gives the title of the multivolume work).
  1108. FUNCTION {format.book.crossref}
  1109. { volume empty$
  1110.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  1111.       "In "
  1112.     }
  1113.     { "Volume" volume tie.or.space.connect
  1114.       " of " *
  1115.     }
  1116.   if$
  1117.   editor empty$
  1118.   editor field.or.null author field.or.null =
  1119.   or
  1120.     { key empty$
  1121.     { series empty$
  1122.         { "need editor, key, or series for " cite$ * " to crossref " *
  1123.           crossref * warning$
  1124.           "" *
  1125.         }
  1126.         { "{\em " * series * "\/}" * }
  1127.       if$
  1128.     }
  1129.     { key * }
  1130.       if$
  1131.     }
  1132.     { format.crossref.editor * }
  1133.   if$
  1134.   " \cite{" * crossref * "}" *
  1135. }
  1136. % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
  1137. % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
  1138. % Often there will be an editor, in which case we use that to construct
  1139. % the cross reference; otherwise we use a nonempty key field or else
  1140. % the booktitle field (which gives the cross-referenced work's title).
  1141. FUNCTION {format.incoll.inproc.crossref}
  1142. { editor empty$
  1143.   editor field.or.null author field.or.null =
  1144.   or
  1145.     { key empty$
  1146.     { booktitle empty$
  1147.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  1148.           crossref * warning$
  1149.           ""
  1150.         }
  1151.         { "In {\em " booktitle * "\/}" * }
  1152.       if$
  1153.     }
  1154.     { "In " key * }
  1155.       if$
  1156.     }
  1157.     { "In " format.crossref.editor * }
  1158.   if$
  1159.   " \cite{" * crossref * "}" *
  1160. }
  1161. % Now we define the type functions for all entry types that may appear
  1162. % in the .BIB file---e.g., functions like `article' and `book'.  These
  1163. % are the routines that actually generate the .BBL-file output for
  1164. % the entry.  These must all precede the READ command.  In addition, the
  1165. % style designer should have a function `default.type' for unknown types.
  1166. % Note: The fields (within each list) are listed in order of appearance,
  1167. % except as described for an `inbook' or a `proceedings'.
  1168. %
  1169. % The article function is for an article in a journal.  An article may
  1170. % CROSSREF another article.
  1171. %    Required fields: author, title, journal, year
  1172. %    Optional fields: volume, number, pages, month, note
  1173. %
  1174. % article ==
  1175. %  BEGIN
  1176. %    output.bibitem
  1177. %    output.check(format.authors,"author")
  1178. %    new.block
  1179. %    output.check(format.title,"title")
  1180. %    new.block
  1181. %    if missing$(crossref) then
  1182. %        output.check(emphasize(journal),"journal")
  1183. %        output(format.vol.num.pages)
  1184. %        output.check(format.date,"year")
  1185. %       else
  1186. %        output.nonnull(format.article.crossref)
  1187. %        output(format.pages)
  1188. %    fi
  1189. %    new.block
  1190. %    output(note)
  1191. %    fin.entry
  1192. %  END
  1193. %
  1194. % The book function is for a whole book.  A book may CROSSREF another book.
  1195. %    Required fields: author or editor, title, publisher, year
  1196. %    Optional fields: volume or number, series, address, edition, month,
  1197. %            note
  1198. %
  1199. % book ==
  1200. %  BEGIN
  1201. %    if empty$(author) then output.check(format.editors,"author and editor")
  1202. %    else    output.check(format.authors,"author")
  1203. %        if missing$(crossref) then
  1204. %            either.or.check("author and editor",editor)
  1205. %        fi
  1206. %    fi
  1207. %    new.block
  1208. %    output.check(format.btitle,"title")
  1209. %    if missing$(crossref) then
  1210. %        output(format.bvolume)
  1211. %        new.block
  1212. %        output(format.number.series)
  1213. %        new.sentence
  1214. %        output.check(publisher,"publisher")
  1215. %        output(address)
  1216. %       else
  1217. %        new.block
  1218. %        output.nonnull(format.book.crossref)
  1219. %    fi
  1220. %    output(format.edition)
  1221. %    output.check(format.date,"year")
  1222. %    new.block
  1223. %    output(note)
  1224. %    fin.entry
  1225. %  END
  1226. %
  1227. % The other entry functions are all quite similar, so no "comment version"
  1228. % will be given for them.
  1229. FUNCTION {article}
  1230. { output.bibitem
  1231.   format.authors "author" output.check
  1232.   new.block
  1233.   crossref missing$
  1234.     { journal emphasize
  1235.       format.vol.num.pages 
  1236.       format.date empty$
  1237.     'skip$
  1238.     { duplicate$ empty$
  1239.         { pop$ format.date paren }
  1240.             { " " * format.date paren * }
  1241.       if$
  1242.     }
  1243.       if$
  1244.       output
  1245.     }
  1246.     { format.article.crossref output.nonnull
  1247.       format.pages output
  1248.     }
  1249.   if$
  1250.   new.block
  1251.   note output
  1252.   fin.entry
  1253. }
  1254. FUNCTION {book}
  1255. { output.bibitem
  1256.   author empty$
  1257.     { format.editors "author and editor" output.check }
  1258.     { format.authors output.nonnull
  1259.       crossref missing$
  1260.     { "author and editor" editor either.or.check }
  1261.     'skip$
  1262.       if$
  1263.     }
  1264.   if$
  1265.   new.block
  1266.   format.btitle "title" output.check
  1267.   crossref missing$
  1268.     { format.bvolume output
  1269.       new.block
  1270.       format.number.series output
  1271.       new.sentence
  1272.       publisher "publisher" output.check
  1273.       address output
  1274.     }
  1275.     { new.block
  1276.       format.book.crossref output.nonnull
  1277.     }
  1278.   if$
  1279.   format.edition output
  1280.   format.date "year" output.check
  1281.   new.block
  1282.   note output
  1283.   fin.entry
  1284. }
  1285. % A booklet is a bound thing without a publisher or sponsoring institution.
  1286. %    Required: title
  1287. %    Optional: author, howpublished, address, month, year, note
  1288. FUNCTION {booklet}
  1289. { output.bibitem
  1290.   format.authors output
  1291.   new.block
  1292.   format.title "title" output.check
  1293.   howpublished address new.block.checkb
  1294.   howpublished output
  1295.   address output
  1296.   format.date output
  1297.   new.block
  1298.   note output
  1299.   fin.entry
  1300. }
  1301. % For the conference entry type, see inproceedings.
  1302. % An inbook is a piece of a book: either a chapter and/or a page range.
  1303. % It may CROSSREF a book.  If there's no volume field, the type field
  1304. % will come before number and series.
  1305. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1306. %    Optional: volume or number, series, type, address, edition, month, note
  1307. FUNCTION {inbook}
  1308. { output.bibitem
  1309.   author empty$
  1310.     { format.editors "author and editor" output.check }
  1311.     { format.authors output.nonnull
  1312.       crossref missing$
  1313.     { "author and editor" editor either.or.check }
  1314.     'skip$
  1315.       if$
  1316.     }
  1317.   if$
  1318.   new.block
  1319.   format.btitle "title" output.check
  1320.   crossref missing$
  1321.     { format.bvolume output
  1322.       format.chapter.pages "chapter and pages" output.check
  1323.       new.block
  1324.       format.number.series output
  1325.       new.sentence
  1326.       publisher "publisher" output.check
  1327.       address output
  1328.     }
  1329.     { format.chapter.pages "chapter and pages" output.check
  1330.       new.block
  1331.       format.book.crossref output.nonnull
  1332.     }
  1333.   if$
  1334.   format.edition output
  1335.   format.date "year" output.check
  1336.   new.block
  1337.   note output
  1338.   fin.entry
  1339. }
  1340. % An incollection is like inbook, but where there is a separate title
  1341. % for the referenced thing (and perhaps an editor for the whole).
  1342. % An incollection may CROSSREF a book.
  1343. %    Required: author, title, booktitle, publisher, year
  1344. %    Optional: editor, volume or number, series, type, chapter, pages,
  1345. %            address, edition, month, note
  1346. FUNCTION {incollection}
  1347. { output.bibitem
  1348.   format.authors "author" output.check
  1349.   new.block
  1350.   format.title "title" output.check
  1351.   new.block
  1352.   crossref missing$
  1353.     { format.in.ed.booktitle "booktitle" output.check
  1354.       format.bvolume output
  1355.       format.number.series output
  1356.       format.chapter.pages output
  1357.       new.sentence
  1358.       publisher "publisher" output.check
  1359.       address output
  1360.       format.edition output
  1361.       format.date "year" output.check
  1362.     }
  1363.     { format.incoll.inproc.crossref output.nonnull
  1364.       format.chapter.pages output
  1365.     }
  1366.   if$
  1367.   new.block
  1368.   note output
  1369.   fin.entry
  1370. }
  1371. % An inproceedings is an article in a conference proceedings, and it may
  1372. % CROSSREF a proceedings.  If there's no address field, the month (& year)
  1373. % will appear just before note.
  1374. %    Required: author, title, booktitle, year
  1375. %    Optional: editor, volume or number, series, pages, address, month,
  1376. %            organization, publisher, note
  1377. FUNCTION {inproceedings}
  1378. { output.bibitem
  1379.   format.authors "author" output.check
  1380.   new.block
  1381.   format.title "title" output.check
  1382.   new.block
  1383.   crossref missing$
  1384.     { format.in.ed.booktitle "booktitle" output.check
  1385.       format.bvolume output
  1386.       format.number.series output
  1387.       format.pages output
  1388.       address empty$
  1389.     { organization publisher new.sentence.checkb
  1390.       organization output
  1391.       publisher output
  1392.       format.date "year" output.check
  1393.     }
  1394.     { address output.nonnull
  1395.       format.date "year" output.check
  1396.       new.sentence
  1397.       organization output
  1398.       publisher output
  1399.     }
  1400.       if$
  1401.     }
  1402.     { format.incoll.inproc.crossref output.nonnull
  1403.       format.pages output
  1404.     }
  1405.   if$
  1406.   new.block
  1407.   note output
  1408.   fin.entry
  1409. }
  1410. % The conference function is included for Scribe compatibility.
  1411. FUNCTION {conference} { inproceedings }
  1412. % A manual is technical documentation.
  1413. %    Required: title
  1414. %    Optional: author, organization, address, edition, month, year, note
  1415. FUNCTION {manual}
  1416. { output.bibitem
  1417.   author empty$
  1418.     { organization empty$
  1419.     'skip$
  1420.     { organization output.nonnull
  1421.       address output
  1422.     }
  1423.       if$
  1424.     }
  1425.     { format.authors output.nonnull }
  1426.   if$
  1427.   new.block
  1428.   format.btitle "title" output.check
  1429.   author empty$
  1430.     { organization empty$
  1431.     { address new.block.checka
  1432.       address output
  1433.     }
  1434.     'skip$
  1435.       if$
  1436.     }
  1437.     { organization address new.block.checkb
  1438.       organization output
  1439.       address output
  1440.     }
  1441.   if$
  1442.   format.edition output
  1443.   format.date output
  1444.   new.block
  1445.   note output
  1446.   fin.entry
  1447. }
  1448. % A mastersthesis is a Master's thesis.
  1449. %    Required: author, title, school, year
  1450. %    Optional: type, address, month, note
  1451. FUNCTION {mastersthesis}
  1452. { output.bibitem
  1453.   format.authors "author" output.check
  1454.   new.block
  1455.   format.title "title" output.check
  1456.   new.block
  1457.   "Master's thesis" format.thesis.type output.nonnull
  1458.   school "school" output.check
  1459.   address output
  1460.   format.date "year" output.check
  1461.   new.block
  1462.   note output
  1463.   fin.entry
  1464. }
  1465. % A misc is something that doesn't fit elsewhere.
  1466. %    Required: at least one of the `optional' fields
  1467. %    Optional: author, title, howpublished, month, year, note
  1468. FUNCTION {misc}
  1469. { output.bibitem
  1470.   format.authors output
  1471.   title howpublished new.block.checkb
  1472.   format.title output
  1473.   howpublished new.block.checka
  1474.   howpublished output
  1475.   format.date output
  1476.   new.block
  1477.   note output
  1478.   fin.entry
  1479.   empty.misc.check
  1480. }
  1481. % A phdthesis is like a mastersthesis.
  1482. %    Required: author, title, school, year
  1483. %    Optional: type, address, month, note
  1484. FUNCTION {phdthesis}
  1485. { output.bibitem
  1486.   format.authors "author" output.check
  1487.   new.block
  1488.   format.btitle "title" output.check
  1489.   new.block
  1490.   "PhD thesis" format.thesis.type output.nonnull
  1491.   school "school" output.check
  1492.   address output
  1493.   format.date "year" output.check
  1494.   new.block
  1495.   note output
  1496.   fin.entry
  1497. }
  1498. % A proceedings is a conference proceedings.
  1499. % If there is an organization but no editor field, the organization will
  1500. % appear as the first optional field (we try to make the first block nonempty);
  1501. % if there's no address field, the month (& year) will appear just before note.
  1502. %    Required: title, year
  1503. %    Optional: editor, volume or number, series, address, month,
  1504. %            organization, publisher, note
  1505. FUNCTION {proceedings}
  1506. { output.bibitem
  1507.   editor empty$
  1508.     { organization output }
  1509.     { format.editors output.nonnull }
  1510.   if$
  1511.   new.block
  1512.   format.btitle "title" output.check
  1513.   format.bvolume output
  1514.   format.number.series output
  1515.   address empty$
  1516.     { editor empty$
  1517.     { publisher new.sentence.checka }
  1518.     { organization publisher new.sentence.checkb
  1519.       organization output
  1520.     }
  1521.       if$
  1522.       publisher output
  1523.       format.date "year" output.check
  1524.     }
  1525.     { address output.nonnull
  1526.       format.date "year" output.check
  1527.       new.sentence
  1528.       editor empty$
  1529.     'skip$
  1530.     { organization output }
  1531.       if$
  1532.       publisher output
  1533.     }
  1534.   if$
  1535.   new.block
  1536.   note output
  1537.   fin.entry
  1538. }
  1539. % A techreport is a technical report.
  1540. %    Required: author, title, institution, year
  1541. %    Optional: type, number, address, month, note
  1542. FUNCTION {techreport}
  1543. { output.bibitem
  1544.   format.authors "author" output.check
  1545.   new.block
  1546.   format.title "title" output.check
  1547.   new.block
  1548.   format.tr.number output.nonnull
  1549.   institution "institution" output.check
  1550.   address output
  1551.   format.date "year" output.check
  1552.   new.block
  1553.   note output
  1554.   fin.entry
  1555. }
  1556. % An unpublished is something that hasn't been published.
  1557. %    Required: author, title, note
  1558. %    Optional: month, year
  1559. FUNCTION {unpublished}
  1560. { output.bibitem
  1561.   format.authors "author" output.check
  1562.   new.block
  1563.   format.title "title" output.check
  1564.   new.block
  1565.   note "note" output.check
  1566.   format.date output
  1567.   fin.entry
  1568. }
  1569. % We use entry type `misc' for an unknown type; BibTeX gives a warning.
  1570. FUNCTION {default.type} { misc }
  1571. % Here are macros for common things that may vary from style to style.
  1572. % Users are encouraged to use these macros.
  1573. %
  1574. % Months are either written out in full or abbreviated
  1575. MACRO {jan} {"Jan."}
  1576. MACRO {feb} {"Feb."}
  1577. MACRO {mar} {"Mar."}
  1578. MACRO {apr} {"Apr."}
  1579. MACRO {may} {"May"}
  1580. MACRO {jun} {"June"}
  1581. MACRO {jul} {"July"}
  1582. MACRO {aug} {"Aug."}
  1583. MACRO {sep} {"Sept."}
  1584. MACRO {oct} {"Oct."}
  1585. MACRO {nov} {"Nov."}
  1586. MACRO {dec} {"Dec."}
  1587. % Journals are either written out in full or abbreviated;
  1588. % the abbreviations are like those found in ACM publications.
  1589. %
  1590. % To get a completely different set of abbreviations, it may be best to make
  1591. % a separate .bib file with nothing but those abbreviations; users could then
  1592. % include that file name as the first argument to the \bibliography command
  1593. MACRO {acmcs} {"ACM Comput. Surv."}
  1594. MACRO {acta} {"Acta Inf."}
  1595. MACRO {cacm} {"Commun. ACM"}
  1596. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1597. MACRO {ibmsj} {"IBM Syst.~J."}
  1598. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1599. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1600. MACRO {ieeetcad}
  1601.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1602. MACRO {ipl} {"Inf. Process. Lett."}
  1603. MACRO {jacm} {"J.~ACM"}
  1604. MACRO {jcss} {"J.~Comput. Syst. Sci."}
  1605. MACRO {scp} {"Sci. Comput. Programming"}
  1606. MACRO {sicomp} {"SIAM J. Comput."}
  1607. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1608. MACRO {tods} {"ACM Trans. Database Syst."}
  1609. MACRO {tog} {"ACM Trans. Gr."}
  1610. MACRO {toms} {"ACM Trans. Math. Softw."}
  1611. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1612. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1613. MACRO {tcs} {"Theoretical Comput. Sci."}
  1614. %% /usr/local/lib/tex/bibtex/phyjfull.btx, Tue Jun 30 08:37:48 1992
  1615. %% Edit by Nelson H. F. Beebe <beebe@alfred.math.utah.edu>
  1616. %% Change file names in leading comment
  1617. % Journal Title Abbreviations from the Physical Review Style and Notation
  1618. %    Guide, July, 1983, in BAPS Vol. 28.
  1619. %  Selected by Cris Barnes and Charles Karney, March 1988
  1620. % IMPORTANT!! Don't make changes to this file without making the
  1621. %           corresponding changes to
  1622. %            phyjabb.bib
  1623. %            phyjabb.btx
  1624. MACRO {advp} {"Advances in Physics"}
  1625. MACRO {ajp} {"American Journal of Physics"}
  1626. MACRO {ao} {"Applied Optics"}
  1627. MACRO {apl} {"Applied Physics Letters"}
  1628. MACRO {apj} {"Astrophysical Journal"}
  1629. MACRO {baps} {"Bulletin of the American Physical Society"}
  1630. MACRO {cpc} {"Computer Physics Communications"}
  1631. MACRO {cppcf} {"Comments on Plasma Physics and Controlled Fusion"}
  1632. MACRO {fed} {"Fusion Engineering and Design"}
  1633. MACRO {ft} {"Fusion Technology"}
  1634. MACRO {ieeens} {"IEEE Transactions on Nuclear Science"}
  1635. MACRO {ieeeps} {"IEEE Transactions on Plasma Science"}
  1636. MACRO {ijimw} {"International Journal of Infrared and Millimeter Waves"}
  1637. MACRO {ip} {"Infrared Physics"}
  1638. MACRO {jap} {"Journal of Applied Physics"}
  1639. MACRO {jcp} {"Journal of Computational Physics"}
  1640. MACRO {jetp} {"Soviet Physics-JETP"}
  1641. MACRO {jfe} {"Journal of Fusion Energy"}
  1642. MACRO {jfm} {"Journal of Fluid Mechanics"}
  1643. MACRO {jgr} {"Journal of Geophysical Research"}
  1644. MACRO {jmp} {"Journal of Mathematical Physics"}
  1645. MACRO {jne} {"Journal of Nuclear Energy"}
  1646. MACRO {jnec} {"Journal of Nuclear Energy, Part C: Plasma Physics, Accelerators, Thermonuclear Research"}
  1647. MACRO {jnm} {"Journal of Nuclear Materials"}
  1648. MACRO {josa} {"Journal of the Optical Society of America"}
  1649. MACRO {jpp} {"Journal of Plasma Physics"}
  1650. MACRO {jpsj} {"Journal of the Physical Society of Japan"}
  1651. MACRO {jvst} {"Journal of Vacuum Science and Technology"}
  1652. MACRO {nedf} {"Nuclear Engineering and Design/Fusion"}
  1653. MACRO {nf} {"Nuclear Fusion"}
  1654. MACRO {nim} {"Nuclear Instruments and Methods"}
  1655. MACRO {nimpr} {"Nuclear Instruments and Methods in Physics Research"}
  1656. MACRO {nt/f} {"Nuclear Technology/Fusion"}
  1657. MACRO {pf} {"Physics of Fluids"}
  1658. MACRO {pfa} {"Physics of Fluids A: Fluid Dynamics"}
  1659. MACRO {pfb} {"Physics of Fluids B: Plasma Physics"}
  1660. MACRO {pl} {"Physics Letters"}
  1661. MACRO {pla} {"Physics Letters A"}
  1662. MACRO {pnas} {"Proceedings of the National Academy of Sciences of the USA"}
  1663. MACRO {pp} {"Plasma Physics"}
  1664. MACRO {ppcf} {"Plasma Physics and Controlled Fusion"}
  1665. MACRO {prl} {"Physical Review Letters"}
  1666. MACRO {pr} {"Physical Review"}
  1667. MACRO {pra} {"Physical Review A: General Physics"}
  1668. MACRO {ps} {"Physica Scripta"}
  1669. MACRO {rmp} {"Reviews of Modern Physics"}
  1670. MACRO {rsi} {"Review of Scientific Instruments"}
  1671. MACRO {sjpp} {"Soviet Journal of Plasma Phys."}
  1672. MACRO {spd} {"Soviet Physics-Doklady"}
  1673. MACRO {sptp} {"Soviet Physics-Technical Physics"}
  1674. MACRO {spu} {"Soviet Physics-Uspeki"}
  1675. % Now we read in the .BIB entries.
  1676. READ
  1677. % The sortify function converts to lower case after purify$ing; it's
  1678. % used in sorting and in computing alphabetic labels after sorting
  1679. %
  1680. % The chop.word(w,len,s) function returns either s or, if the first len
  1681. % letters of s equals w (this comparison is done in the third line of the
  1682. % function's definition), it returns that part of s after w.
  1683. % This long comment applies only to alphabetic labels
  1684. %
  1685. % The format.lab.names function makes a short label by using the initials of
  1686. % the von and Last parts of the names (but if there are more than four names,
  1687. % (i.e., people) it truncates after three and adds a superscripted "+";
  1688. % it also adds such a "+" if the last of multiple authors is "others").
  1689. % If there is only one name, and its von and Last parts combined have just
  1690. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1691. % we take the first three letters of the last name.  The boolean
  1692. % et.al.char.used tells whether we've used a superscripted "+", so that we
  1693. % know whether to include a LaTeX macro for it.
  1694. %
  1695. % format.lab.names(s) ==
  1696. %  BEGIN
  1697. %    numnames := num.names$(s)
  1698. %    if numnames > 1 then
  1699. %        if numnames > 4 then
  1700. %        namesleft := 3
  1701. %        else
  1702. %        namesleft := numnames
  1703. %        nameptr := 1
  1704. %        nameresult := ""
  1705. %        while namesleft > 0
  1706. %          do
  1707. %        if (name_ptr = numnames) and
  1708. %             format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
  1709. %           then nameresult := nameresult * "{\etalchar{+}}"
  1710. %            et.al.char.used := true
  1711. %           else nameresult := nameresult *
  1712. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1713. %        nameptr := nameptr + 1
  1714. %        namesleft := namesleft - 1
  1715. %          od
  1716. %        if numnames > 4 then
  1717. %        nameresult := nameresult * "{\etalchar{+}}"
  1718. %        et.al.char.used := true
  1719. %    else
  1720. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1721. %        if text.length$(t) < 2 then    % there's just one name-token
  1722. %        nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
  1723. %        else
  1724. %        nameresult := t
  1725. %        fi
  1726. %    fi
  1727. %    return nameresult
  1728. %  END
  1729. %
  1730. % Exactly what fields we look at in constructing the primary part of the label
  1731. % depends on the entry type; this selectivity (as opposed to, say, always
  1732. % looking at author, then editor, then key) helps ensure that "ignored" fields,
  1733. % as described in the LaTeX book, really are ignored.  Note that MISC is part
  1734. % of the deepest `else' clause in the nested part of calc.label; thus, any
  1735. % unrecognized entry type in the database is handled correctly.
  1736. %
  1737. % There is one auxiliary function for each of the four different sequences of
  1738. % fields we use.  The first of these functions looks at the author field, and
  1739. % then, if necessary, the key field.  The other three functions, which might
  1740. % look at two fields and the key field, are similar, except that the key field
  1741. % takes precedence over the organization field (for labels---not for sorting).
  1742. %
  1743. % The calc.label function calculates the preliminary label of an entry, which
  1744. % is formed by taking three letters of information from the author or editor or
  1745. % key or organization field (depending on the entry type and on what's empty,
  1746. % but ignoring a leading "The " in the organization), and appending the last
  1747. % two characters (digits) of the year. It is an error if the appropriate fields
  1748. % among author, editor, organization, and key are missing, and we use
  1749. % the first three letters of the cite$ in desperation when this happens.
  1750. % The resulting label has the year part, but not the name part, purify$ed
  1751. % (purify$ing the year allows some sorting shenanigans by the user).
  1752. %
  1753. % This function also calculates the version of the label to be used in sorting.
  1754. %
  1755. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1756. % otherwise identical labels, but we can't calculated those "extra.label"s
  1757. % until after sorting.
  1758. %
  1759. % calc.label ==
  1760. %  BEGIN
  1761. %    if type$ = "book" or "inbook" then
  1762. %        author.editor.key.label
  1763. %    else if type$ = "proceedings" then
  1764. %        editor.key.organization.label
  1765. %    else if type$ = "manual" then
  1766. %        author.key.organization.label
  1767. %    else
  1768. %        author.key.label
  1769. %    fi fi fi
  1770. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1771. %        % assuming we will also sort, we calculate a sort.label
  1772. %    sort.label := sortify(label), but use the last four, not two, digits
  1773. %  END
  1774. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1775. % The presort key contains a number of "sortify"ed strings, concatenated
  1776. % with multiple blanks between them.  This makes things like "brinch  per"
  1777. % come before "brinch hansen  per".
  1778. %
  1779. % The fields used here are: the sort.label for alphabetic labels (as set by
  1780. % calc.label), followed by the author names (or editor names or organization
  1781. % (with a leading "The " removed) or key field, depending on entry type and on
  1782. % what's empty), followed by year, followed by the first bit of the title
  1783. % (chopping off a leading "The ", "A ", or "An ").
  1784. % Names are formatted: Von Last First Junior.
  1785. % The names within a part will be separated by a single blank
  1786. % (such as "brinch hansen"), two will separate the name parts themselves
  1787. % (except the von and last), three will separate the names,
  1788. % four will separate the names from year (and from label, if alphabetic),
  1789. % and four will separate year from title.
  1790. %
  1791. % The sort.format.names function takes an argument that should be in
  1792. % BibTeX name format, and returns a string containing "   "-separated
  1793. % names in the format described above.  The function is almost the same
  1794. % as format.names.
  1795. % This long comment applies only to alphabetic labels, when sorted
  1796. %
  1797. % Now comes the final computation for alphabetic labels, putting in the 'a's
  1798. % and 'b's and so forth if required.  This involves two passes: a forward
  1799. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  1800. % to put in the 'a's (we don't want to put in 'a's unless we know there
  1801. % are 'b's).
  1802. % We have to keep track of the longest (in width$ terms) label, for use
  1803. % by the "thebibliography" environment.
  1804. %
  1805. % VAR: longest.label, last.sort.label, next.extra: string
  1806. %      longest.label.width, last.extra.num: integer
  1807. %
  1808. % initialize.longest.label ==
  1809. %  BEGIN
  1810. %    longest.label := ""
  1811. %    last.sort.label := int.to.chr$(0)
  1812. %    next.extra := ""
  1813. %    longest.label.width := 0
  1814. %    last.extra.num := 0
  1815. %  END
  1816. %
  1817. % forward.pass ==
  1818. %  BEGIN
  1819. %    if last.sort.label = sort.label then
  1820. %        last.extra.num := last.extra.num + 1
  1821. %        extra.label := int.to.chr$(last.extra.num)
  1822. %    else
  1823. %        last.extra.num := chr.to.int$("a")
  1824. %        extra.label := ""
  1825. %        last.sort.label := sort.label
  1826. %    fi
  1827. %  END
  1828. %
  1829. % reverse.pass ==
  1830. %  BEGIN
  1831. %    if next.extra = "b" then
  1832. %        extra.label := "a"
  1833. %    fi
  1834. %    label := label * extra.label
  1835. %    if width$(label) > longest.label.width then
  1836. %        longest.label := label
  1837. %        longest.label.width := width$(label)
  1838. %    fi
  1839. %    next.extra := extra.label
  1840. %  END
  1841. % Now comes the computation for numeric labels.
  1842. % We use either the sorted order or original order.
  1843. % We still have to keep track of the longest (in width$ terms) label, for use
  1844. % by the "thebibliography" environment.
  1845. STRINGS { longest.label }
  1846. INTEGERS { number.label longest.label.width }
  1847. FUNCTION {initialize.longest.label}
  1848. { "" 'longest.label :=
  1849.   #1 'number.label :=
  1850.   #0 'longest.label.width :=
  1851. }
  1852. FUNCTION {longest.label.pass}
  1853. { number.label int.to.str$ 'label :=
  1854.   number.label #1 + 'number.label :=
  1855.   label width$ longest.label.width >
  1856.     { label 'longest.label :=
  1857.       label width$ 'longest.label.width :=
  1858.     }
  1859.     'skip$
  1860.   if$
  1861. }
  1862. EXECUTE {initialize.longest.label}
  1863. ITERATE {longest.label.pass}
  1864. % Now we're ready to start writing the .BBL file.
  1865. % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
  1866. % label; next comes stuff from the `preamble' command in the database files.
  1867. % Then we give an incantation containing the command
  1868. %     \begin{thebibliography}{...}
  1869. % where the `...' is the longest label.
  1870. %
  1871. % We also call init.state.consts, for use by the output routines.
  1872. FUNCTION {begin.bib}
  1873. { preamble$ empty$
  1874.     'skip$
  1875.     { preamble$ write$ newline$ }
  1876.   if$
  1877.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1878. }
  1879. EXECUTE {begin.bib}
  1880. EXECUTE {init.state.consts}
  1881. % Now we produce the output for all the entries
  1882. ITERATE {call.type$}
  1883. % Finally, we finish up by writing the `\end{thebibliography}' command.
  1884. FUNCTION {end.bib}
  1885. { newline$
  1886.   "\end{thebibliography}" write$ newline$
  1887. }
  1888. EXECUTE {end.bib}
  1889.